{% extends '/pg/index.html' %}
{% block operation %}
<ul class="breadcrumb">
  <li><a href="/pg">Home</a></li>
  <li><a href="/pg/anagrafiche">Anagrafiche</a></li>
  <li class="active">Utenti</li>
</ul>
<h2 class="text-center">Utenti</h2>

{% include "pg/btn_action.html" with context %}

{% include "pg/filterkey/fk_utente.html" with context %}

{%endblock%}

{% block custom_js %}
<script type="text/javascript">
$(document).ready(function () {

$(".Preview").hide()
$("#anteprima").hide()
$(".Edit_dao").hide()
$("#edit_dao").hide()
$("#print_dao").hide()

$('#tableContainer_ac').jtable({
    title: 'Tabella Utente',
    messages: window.italianMessages,
    defaultDateFormat:"dd-mm-yy",
    paging: true,
    pageSize: 20,
    sorting: true,
    selecting: true,
    create:false,

    actions: {
        listAction: '/pg/ac_Utente/List',
        deleteAction: '/pg/ac_Utente/Delete'
    },
    fields: {
        id: {key: true,
            create: false,
            edit: false,
            list: false
        },
        username: {
            title: 'Username',
            width: '4%',
        },
        email: {
            title: 'Email',
            width: '4%',
        },
        registration_date: {
            title: 'Data Registrazione',
            width: '4%',
        },
        ruolo: {
            title: 'Ruolo',
            width: '4%',
        },
        active: {
            title: 'Attivo',
            width: '3%',
        },
        email_confirmed: {
            title: 'Conferma Email',
            width: '3%',
        },
        privacy: {
            title: 'Accetazione Privacy',
            width: '3%',
        },
        mailing_list: {
            title: 'Mailing List',
            width: '4%',
        },



    },
    selectionChanged: function () {
    //Get all selected rows

    var $selectedRows = $('#tableContainer_ac').jtable('selectedRows');
    $("#anteprima").hide();
    $('.Preview').empty();
    $("#print_dao").hide();
    $("#edit_dao").hide();

    if ($selectedRows.length > 0) {
        //Show selected rows
        $("#edit_dao").show()
        $("#anteprima").show()
        //$("#print_dao").show()

    }
},

}); //fine tabella


$('#tableContainer_ac').jtable('load');

$('#anteprima').attr('preview', '/pg/ac_Utente/Preview');
$('#new_dao').attr('nuovo_dao', '/pg/ac_Utente/Edit');
$('#edit_dao').attr('modifica_dao', '/pg/ac_Utente/Edit');


// search Part  --------------//
$("#conferma_dao").hide();
filtra = function() {
    $('#tableContainer_ac').jtable('load', {
        fk_username: $('#fk_username').val(),
        fk_email: $('#fk_email').val(),
        fk_id_role: $('#fk_id_role').val(),
    });
  };
ruoloUte()

});
</script>
{% endblock %}
